<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>我的任务</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
        <div>
        	<div class="searchArea">
					    <form id="searchBar">
					        <div class="fieldset1 clearFix">
					            <div class="fieldBox">
					                <div class="label" style="width: 60px;">流程名称</div>
					                <div class="field">
					                    <input name="flowDefNm" id="flowDefNm" type="text" class="ui-textbox" value="">
					                </div>
					            </div>
					            <!-- <div class="fieldBox">
					                <div class="label" style="width: 60px;">承租人</div>
					                <div class="field">
					                    <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
					                </div>
					            </div> -->
					            
					            <div class="fieldBox col_50">
				                    <div class="label" style="width: 60px;">组织机构</div>
				                    <div class="field">
				                        <input name="orgDispNm" id="orgDispNm" type="text" value="" placeholder="请选择" ltype="combobox">
				                    </div>
				                </div>
					            
					            <div class="fieldBox">
					                <div class="label" style="width: 60px;">业务模式</div>
					                <div class="field">
					                    <select name="businessType" id="businessType">
					                       <option value="" seleted>请选择</option>
					                       <c:forEach items="${businessTypeList }" var="item">
					                         	<option value="${item.key }">${item.value }</option>
					                       </c:forEach>
					                    </select>
					                </div>
					            </div>
					            
					            <div class="fieldBox">
					                <div class="label" style="width: 60px;">开始时间</div>
					                <div class="field">
					                     <input  name="startTmStart" id="startTmStart" type="text" class="ui-datepicker" value="">
					                </div>
					            </div>
					            <div class="fieldBox">
					                <div class="label" style="width: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;至</div>
					                <div class="field">
					                     <input  name="startTmEnd" id="startTmEnd" type="text" class="ui-datepicker" value="">
					                </div>
					            </div>
					             <div class="fieldBox">
					                <div class="label" style="width: 60px;">结束时间</div>
					                <div class="field">
					                     <input name="endTmStart" id="endTmStart" type="text" class="ui-datepicker" value=""> 
					                </div>
					            </div>
					            <div class="fieldBox">
					                <div class="label" style="width: 60px;">&nbsp;&nbsp;&nbsp;&nbsp;至</div>
					                <div class="field">
					                     <input name="endTmEnd" id="endTmEnd" type="text" class="ui-datepicker" value="">
					                </div>
					            </div>
					            
								<div class="fieldBox">
					                <div class="label" style="width: 60px;">任务源</div>
					                <div class="field">
					                    <select name="bizResCd" id="bizResCd">
					                       <option value="" seleted>请选择</option>
					                       <c:forEach items="${businessSourceList }" var="item">
					                        	<option value="${item.key }">${item.value }</option>
					                       </c:forEach>
					                    </select>
					                </div>
					            </div>
								    
								<div class="fieldBox">
					                <div class="label" style="width: 60px;">发起人</div>
					                <div class="field">
					                    <input name="initiator" id="initiator" type="text" class="ui-textbox" value="">
					                </div>
					            </div>    
					            
					            <div class="fieldBox">
					                <div class="label" style="width: 60px;">关键字</div>
					                <div class="field">
					                    <input name="viKey" id="viKey" type="text" class="ui-textbox" value="">
					                </div>
					            </div> 
								<div class="fieldBox">
					                <div class="label" style="width: 60px;">流程编号</div>
					                <div class="field">
					                    <input name="procNo" id="procNo" type="text" class="ui-textbox" value="">
					                </div>
					            </div>         
					            <div class="clearFix"></div>
					            <div class="btnsBox">
					               <span id="searchBtn" class="sq-button sq-button-round">查询</span>
					               <span onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
					               <span onclick="showFlow();" class="sq-button sq-button-round">查看</span>
					               <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
					            </div>
					        </div>
					    </div>
					</form>
           <div id="ligergridWJ" class="sq-grid"></div>
        </div>
    </div>

<script type="text/javascript">
	var gridWJ = null;
	var pageInApp={}; // to 下一级子窗口 接口
    var pageInTab=null;
    var loadedTabs=[]
	$(function () {
		initGridWJ();//初始化完结列表
		initOrgTree();
	    $("#searchBar").ligerForm();
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         data["startTmStart"] = $("#startTmStart").val();
	         data["startTmEnd"] = $("#startTmEnd").val();
	         data["endTmStart"] = $("#endTmStart").val();
	         data["endTmEnd"] = $("#endTmEnd").val();
	         
	         if(searchOrgTree.treeManager.getSelected()){
	        	 var orgDispNm = searchOrgTree.treeManager.getSelected().data['orgDispNm'];
		         if(orgDispNm){
		        	 data["orgDispNm"] = orgDispNm;
		         }
	         }
	         
	         //业务类型要名字 businessType
	         var _businessType = $("#businessType").val();
	         //alert(_businessType);
	         var _businessTypeName = $("select[name=businessType] option[value='"+_businessType+"']").text();
	         if(_businessTypeName == "请选择"){
	         	_businessTypeName = "";
	         }
	         data["businessType"] = _businessTypeName;//用中文作为查询条件
	         
	         for (name in data){
	 	            gridWJ.setParm(name,data[name]);
	 	     };
	 	     gridWJ.reload();
	    });
	});
    
    //初始化查询条件中的下拉树
    var searchOrgTree;
    function initOrgTree(){
    	 searchOrgTree = $("#orgDispNm").ligerComboBox({
             selectBoxWidth: 240,
             selectBoxHeight: 150,
             treeLeafOnly: false, //限制只能选叶节点，父节点不能点击
             tree: {
                 ajaxType: 'get',
                 idFieldName:'text',
                 checkbox: false,
                 parentIcon: "none",
                 childIcon: "none"
             }
         });
    	 
    	 var _url = '<%=path%>/system/sysOrg/searchOrgTree.do';
    	 AjaxUtils.ajaxGet(_url, {}, function(msg){
    		 if(msg.success == 1){
  				searchOrgTree.treeManager.setData(msg.data);
  				searchOrgTree.clear();
  			 }else{
  				UIUtils.alertError(msg.info);
  			 }
    	 },false);
    }
    
  	//初始化完结列表
    function initGridWJ(){
    	$("#ligergridWJ").ligerGrid({
	    	url: '<%=path%>/flow/flow/initMyTaskWJList.do',
	    	method : 'get',
	        columns: [
				/* { display: '任务级别', name: 'priorityNm',  width: 120, enabledSort:false}, */
	            { display: '任务源', name: 'taskTypeNm',  width: 100, enabledSort:false},
	            { display: '流程名称', name: 'processDefinitionNm',  minWidth: 200, enabledSort:false},
	            { display: '流程编号', name: 'procNo',  width: 100, enabledSort:false},
	            { display: '处理节点', name: 'name',  width: 100, enabledSort:false},
	            /* { display: '关键字', name: 'taskDesc', minWidth: 140 , enabledSort:false}, */
	            /* { display: '承租人', name: '', minWidth: 140 , enabledSort:false},
	            { display: '项目名称', name: '', minWidth: 140 , enabledSort:false},
	            { display: '事业部', name: '', minWidth: 140 , enabledSort:false},
	            { display: '大区', name: '', minWidth: 140 , enabledSort:false},
	            { display: '省公司', name: '', minWidth: 140 , enabledSort:false},
	            { display: '分公司', name: '', minWidth: 140 , enabledSort:false}, */
	            /* { display: '业务类型', name: 'businessTypeNm', minWidth: 120 , enabledSort:false}, */
	            { display: '发起人', name: 'initiatorNm', width: 60,align:'left' , enabledSort:false},
	            { display: '结束时间', name: 'endTime', minWidth: 140 , render:renderDate, enabledSort:false},
	            { display: '处理状态', name: 'procStatusNm', minWidth: 60 , enabledSort:false},
	            { display: '新处理人', name: 'assigneeNm', minWidth: 120 , enabledSort:false,
	            	render: function (rowdata, rowindex, value){
	            		return UIUtils.showColumnTip(value);
	                }
				},
	            { display: '原处理人', name: 'ownerNm', minWidth: 80 , enabledSort:false},
	            { display: '任务创建时间', name: 'startTime', minWidth: 140 , render:renderDate, enabledSort:false},
	            { display: '当前耗时', name: 'durationStr', minWidth: 140 , enabledSort:false}
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-30,
	        //isScroll: false,
	        checkbox:true,
	        rownumbers:true/* ,
	        onRenderComplete: function () {
	        	iframeResize ();
	        } */
	    });
    	gridWJ = liger.get("ligergridWJ");
    	gridWJ.setHeight(100);
    	gridWJ.options.isSingleCheck=true;
    }
	
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}
	
	//查看流程
	function showFlow(){
		var selectedRows = gridWJ.getSelectedRows();
		if(selectedRows.length != 1){
			UIUtils.alertWarning(LogUtils.LOG_CMM_SELECT_ONLY_A_ROW);
			return;
		}
		//非业务参数
		var _name = selectedRows[0].name;
		var _id = selectedRows[0].id;
		
		//业务参数
		var _processDefinitionId = selectedRows[0].processDefinitionId;//流程定义ID
		var _processInstanceId = selectedRows[0].processInstanceId;//流程实例ID
		var _taskId = selectedRows[0].taskId;//任务ID
		var _assignable = selectedRows[0].assignable;//是否可分配按钮的标识 true fasle
		var _formUrl = selectedRows[0].formUrl;//表单地址
		var _flowList = selectedRows[0].sequenceFlowVOList;//任务分出连线
		var _processDefinitionKey = selectedRows[0].processDefinitionKey;//流程定义Key
		var _taskDefKey = selectedRows[0].taskDefKey;//任务定义Key
		var _businessKey = selectedRows[0].businessKey;//业务数据ID
		var _taskType = selectedRows[0].taskType;//任务类型标识,后面区分按钮的显示与否
		var _status = selectedRows[0].status;//任务状态
		var _assignee = selectedRows[0].assignee;//
		var _businessType = selectedRows[0].businessType;//业务类型
		var _originTaskId = selectedRows[0].originTaskId;//原始任务ID
		var _beanName = selectedRows[0].beanName;//业务Bean
		var params = "processDefinitionId="+_processDefinitionId+
			"&processInstanceId="+_processInstanceId+
			"&taskId="+_taskId+
			"&businessKey="+_businessKey+
			"&assignable="+_assignable+
			"&formUrl="+_formUrl+
			"&taskType="+_taskType+
			"&processDefinitionKey="+_processDefinitionKey+
			"&taskDefKey="+_taskDefKey+
			"&status="+_status+
			"&assignee="+_assignee+
			"&businessType="+_businessType+
			"&originTaskId="+_originTaskId+
			"&beanName="+_beanName+
			"&flowList="+JSON.stringify(_flowList);
			Add_navTab('tab_flow_show_'+_taskId, _name, '<%=path%>/flow/flow/toFlowShowPage.do?' + params)
	}
	
	function clearBtn(){
		$("#resetBtn").click();  //重置 input-text
		var form = liger.get("searchBar");
		$("#orgCd").val(" ");
        form.setData({  //重置select等特殊表单
            //"orgCd": "",
            "businessType":" ",
            "bizResCd":" "
        });
        searchOrgTree.clear();
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
</script>

</body>
</html>